#lang racket

(define (make-account balance password)
  (let ((tries 0))
    (begin (define (call-the-cops) (display "the cops are comming!!!\n"))
           (define (blind x) (display ""))
           (define (withdraw amount)
             (if (>= balance amount)
                 (begin (set! balance (- balance amount))
                        balance)
                 "not enough credits on account"))
           (define (deposit amount)
             (set! balance (+ balance amount))
             balance)
           (define (dispatch pw m)
             (if (eq? password pw)
                 (begin (set! tries 0)
                        (cond ((eq? m 'withdraw) withdraw)
                              ((eq? m 'deposit) deposit)
                              (else (error "unknown parameter: " 
                                           m))))
                 (begin (set! tries (+ tries 1))
                        (if (< tries 2)
                            (display "wrong password\n")
                            (call-the-cops)) 
                        blind)))
           dispatch)))


(define acc (make-account 100 '1024))

((acc '1024 'withdraw) 40)

((acc '1023 'deposit) 50)

((acc '1024 'withdraw) 40)

((acc '1023 'deposit) 50)


